/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cardamy.lib.deck;

import org.cardamy.core.card.Card;
import org.cardamy.core.card.attr.CardAttribute;
import org.cardamy.core.card.attr.CardAttributeHolder;
import org.cardamy.core.deck.Deck;
import org.cardamy.core.deck.DeckBuilder;
import org.cardamy.lib.card.attr.SpanishSuitCardAttribute;
import org.cardamy.lib.card.attr.SpanishSuitCardAttribute.Suit;

/**
 *
 * @author Santiago
 */
public class SpanishDeckBuilder extends DeckBuilder {
    
    protected String[] _enum;
    protected int[]    _rank;
    protected Suit[]   _suits  = Suit.values();
    
    protected String[] _longDeckEnum  = "1,2,3,4,5,6,7,8,9,10,11,12".split(",");
    protected int[]    _longDeckRank  = {1,2,3,4,5,6,7,8,9,10,11,12};
    protected String[] _shortDeckEnum = "1,2,3,4,5,6,7,10,11,12".split(",");
    protected int[]    _shortDeckRank = {1,2,3,4,5,6,7,10,11,12};
    
    protected boolean _isShortDeck = false;
    
    public SpanishDeckBuilder(boolean isShort) {
        _isShortDeck = isShort;
    }
    
    @Override
    public Deck create() {
        _rank = _longDeckRank;
        _enum = _longDeckEnum;
        if(_isShortDeck) {
            _rank = _shortDeckRank;
            _enum = _shortDeckEnum;
        }
        int totalCards = _rank.length;
        Deck deck = new Deck();
        
        for(Suit suit : _suits) {
            for ( int i = 0; i < totalCards; i++ ) {

                CardAttributeHolder attr = new CardAttributeHolder();
                attr.addAttr(new CardAttribute("Enum", _enum[i]))
                        .addAttr(new CardAttribute(
                            "Rank", String.valueOf(_rank[i])
                        ))
                        .addAttr(new SpanishSuitCardAttribute("Suit", suit));
                deck.addCard(new Card(attr));
            }
        }
        return deck;
    }
   
}
